// hyb_yl/mysubpages/pages/capitacenter/capitacenter.js
var wxCharts = require('../../../../template/wxcharts.js');
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    capitalist: [],
    y_zhou: [],
    // 本月天
    x_zhou: [],
    z_zhou: [],
  },
  capitainfor: function (e) {
    var keyword = e.currentTarget.dataset.keywords;
    var did = e.currentTarget.dataset.did;
    wx.navigateTo({
      url: '/hyb_yl/lvtongserver/pages/capitadetail/capitadetail?keyword=' + keyword + '&did=' + did,
    })

  },
  tixian: function () {
    var that = this;
    var money = that.data.list.count;
    if (money == '0' || money == '0.00' || money == '') {
      wx.showModal({
        title: '提示',
        content: "暂无可提现金额",

      })
    } else {
      app.util.request({
        'url': "entry/wxapp/green.is_cash",
        data: {
          did: wx.getStorageSync('did'),
          money: money
        },
        success: function (res) {
          if (res.data.code == '1') {
            wx.showModal({
              title: '提示',
              content: res.data.message
            })
          } else {
            wx.navigateTo({
              url: '/hyb_yl/twosubpages/pages/my_ti/my_ti?did=' + wx.getStorageSync('did'),
            })
          }
        }
      })


    }
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    
    that.getSeven();
  },
  getSeven: function () {
    var that = this;
    app.util.request({
      'url': 'entry/wxapp/green.seven_money',
      'data': {
        openid: wx.getStorageSync('openid')
      },
      success: function (res) {
        var arrs = res.data;
        that.setData({
          tian: res.data
        })

        var obj = {
          news: {
            money: 0,
            num: 0
          },
          tian: arrs
        };
        var x_zhou = [],
          y_zhou = [];
        var z_zhou = [];
        for (var i in obj.tian) {
          x_zhou.push(obj.tian[i].date);
          y_zhou.push(obj.tian[i].money);
          z_zhou.push(obj.tian[i].pay);
        }
        that.setData({
          x_zhou: x_zhou,
          y_zhou: y_zhou,
          z_zhou: z_zhou,
          num: obj.news.num,
          money: obj.news.money
        })
        that.zhexiantu("lineCanvas", "#F2AA56", "#0088DE", that.data.x_zhou, that.data.y_zhou, that.data.z_zhou);

      }
    })

    //   },
    // })
  },
  zhexiantu(id, color, colors, x_zhou, y_zhou, z_zhou) {
    var that = this;
    //折线图开始
    try {
      var res = wx.getSystemInfoSync();
      var windowWidth = res.windowWidth;

      var windowHeight = res.windowHeight * 0.4;
    } catch (e) {
      console.error("系统信息错误")
    };
    new wxCharts({
      canvasId: id,
      type: "line",
      categories: x_zhou,
      animation: true,
      series: [{
        data: y_zhou,
        format: function (val, name) {
          return val + ' 元';
        },
        color: color
      }, {
        data: z_zhou,
        format: function (val, name) {
          return val + ' 元';
        },
        color: colors
      }],
      xAxis: {
        disableGrid: true
      },
      yAxis: {
        // disabled: true
      },
      width: windowWidth,
      height: windowHeight,
      dataLabel: true,
      dataPointShape: true,
      extra: {
        lineStyle: 'curve'
      },
      legend: false
    })


  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    app.util.request({
      'url': "entry/wxapp/green.guidance_pay",
      data: {
        openid: wx.getStorageSync('openid'),
      },
      success: function (res) {
        that.setData({
          list: res.data
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})